package com.lg;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

public class MybatisGenerater {
	public static void main(String[] args) throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {
		ArrayList<String> arrayList = new ArrayList<>();
		boolean overwrite = true;
		String genCfg = "/generatorConfig.xml";
		File file = new File(MybatisGenerater.class.getResource(genCfg).getFile());
		ConfigurationParser cp = new ConfigurationParser(arrayList);
		Configuration configuration = cp.parseConfiguration(file);
		DefaultShellCallback defaultShellCallback = new DefaultShellCallback(overwrite);
	          MyBatisGenerator myBatisGenerator = new MyBatisGenerator(configuration, defaultShellCallback, arrayList);
	          myBatisGenerator.generate(null);
	}
}
